package search;

import java.util.Iterator;
import java.util.ServiceLoader;

/**
 * Created by shangyanshuo on 2016/10/18.
 */
public class SearchTest {

    public static void main(String[] args) {
        ServiceLoader<Search> s = ServiceLoader.load(Search.class);

        //用这个方法能更清晰的理清ServiceLoader这个工具类的执行逻辑。
        Iterator<Search> searchs = s.iterator();
        while (searchs.hasNext()) {
            Search curSearch = searchs.next();
            curSearch.search("test");
        }

        for (Search search : s){
            search.search("this is work well");
        }
    }

}
